<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<base href='<?php echo base_url()?>'>
<link rel="stylesheet" type="text/css" href="public/common/css/common.css"/>
<link rel="stylesheet" type="text/css" href="public/admin/css/admin.css"/>
<script type="application/javascript" src="public/common/js/jquery.js"></script>
<script>
$(function(){
	$('.table tr').hover(function(){
		$(this).children('td').css('background','#ccffcc');
	},function(){
		$(this).children('td').css('background','white');
	});			   
});
function select_all()
{
	$('.table').find('input:checkbox').attr('checked',true);
}
function select_other()
{
	check_obj = $('.table').find('input:checked');
	$('.table').find('input:checkbox').attr('checked',true);
	check_obj.attr('checked',false);
}
function delete_select_content()
{
	if(confirm('确定删除所选吗？删除后不可恢复！'))
	{
		$('input:checked').each(function(){
			del(this,$(this).val());
		});
	}
}
function delete_product_ask(obj,ask_id)
{
	if(confirm('确定要删除吗？删除后不可恢复！'))
	{
		del(obj,ask_id);
	}
}
function del(obj,ask_id)
{
	$.post("<?php echo site_url('admin/product_ask/delete_product_ask')?>",{ask_id:ask_id},function(result){
		if(result == true)
		{
			$(obj).parent().parent().remove();
		}else{
			alert('删除失败！');		
		}
	});		
}
function shenhe()
{
	$('input:checked').each(function(){
		obj = this;
		$.post('<?php echo site_url("admin/product_ask/shenhe")?>',{ask_id:$(this).val()});	
	});
	alert('审核通过');
	location.reload();
}
</script>
</head>
<body>
	<div class="body">
    	<?php echo $this->position->get_position();?>
        <div class="body_center">
        	<table class="table" style="margin-bottom:0px;">
            	<tr><th>选择</th><th>咨询标题</th><th>产品标题</th><th>咨询用户</th><th>咨询状态</th><th>审核</th><th>咨询时间</th><th>操作</th></tr>
				<?php if($product_ask === FALSE):?>
				<tr><td colspan="6" align="center">没有任何咨询</td></tr>
				<?php else:?>
				<?php foreach($product_ask->result() as $value):?>
                 <tr>
                	<td align="center"><input type="checkbox" value="<?php echo $value->ask_id?>"></td>
                    <td align="center"><?php echo $value->ask_title?></td>
                    <td align="center">
						<?php $product = $this->cic_model->get_one('product',array('product_id'=>$value->product_id))?>
                        <?php if($product):?>
                        <?php echo $product->product_title?>
                        <?php endif;?> 
                    </td>
                    <td align="center"><?php echo $value->ask_user?></td>
                    <td align="center"><?php if($value->ask_status == 1):?><font color="green"">未回复</font><?php elseif($value->ask_status == 2):?>已回复<?php else:?><font color="#FF0000"">未读</font><?php endif;?></td>
                    <td align="center"><?php if($value->ask_shenhe == 1):?>已审核<?php else:?><font color="red">未审核</font><?php endif?></td>
                    <td align="center"><?php echo date('Y-m-d',$value->ask_create_time)?></td>
                    <td align="center"><a href="<?php echo site_url('admin/product_ask/ask_reply/'.$value->ask_id)?>"><?php if($value->ask_status == '2' or $value->ask_status == '0'):?>查看<?php else:?>回复<?php endif?></a> | <a href="javascript:void(0)" onclick="delete_product_ask(this,<?php echo $value->ask_id?>)">删除</a></td>
                </tr>
                <?php endforeach;?>
				<tr>
                	<td colspan="8" align="right">
                    	<input type="button" value="全选" class="button" onclick="select_all()">
                        <input type="button" value="反选" class="button" onclick="select_other()">
                        <input type="button" value="审核" class="button" onclick="shenhe()">
                        <input type="button" value="删除" class="button" onclick="delete_select_content()">
                 	</td>
                </tr>
				<?php endif;?>
            </table>
        </div>
        <div class="page"><?php echo $page?></div>
    </div>
</body>
</html>